package BlockingQueue;

import java.util.concurrent.*;

public class Test {
    public static void main(String[] args) throws InterruptedException {
        //blockingQueue 这里作为阻塞队列,入队的方法是put() ,出队的方法是take() ,因为带有阻塞功能,所以要处理InterruptedException异常
        //作为阻塞队列,那么blockingQueue 就会在队列满了之后再放入元素时进行阻塞, 队列空了之后在取出元素时会产生阻塞
        BlockingQueue<Integer> blockingQueue = new LinkedBlockingQueue<>();
        blockingQueue.put(1);
        Integer tmp = blockingQueue.take();
        System.out.println(tmp);
        tmp = blockingQueue.take();
        blockingQueue.put(2);
        System.out.println(tmp);
    }
}
